﻿/********************************************************************************************************
  1. 스토어드명		: SP_CODE_PATTERN_CUD
  2. 목적 & 기능		: Pattern에 대한 입력,수정,삭제관리 (Cad Code / Part Code / Purchasing Part Code)
  3. 생성일자		: 2014.06.30
  4. 생성자 			: 조범준
  5. Used DB Name	: DB_EDUC
  6. Used DB Table	:
						Create	- STDPATTERN a
						Update	- STDPATTERN a
						Delete	- STDPATTERN a
  7. 실행			:
						SP_CODE_PATTERN_CUD 'CREATE_PATTERN_NAME', '', '', '', '', ''
						SP_CODE_PATTERN_CUD 'UPDATE_PATTERN_NAME', '', '', '', '', ''
						SP_CODE_PATTERN_CUD 'DELETE_PATTERN_NAME', '', '', '', '', ''
 ********************************************************************************************************/
----------------------------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE SP_CODE_PATTERN_CUD
(
	iJOBMODE				IN VARCHAR2,
	iOBJECTID				IN NUMBER,
	iSECTION				IN NUMBER,
	iPATTERN				IN VARCHAR2
)
IS
BEGIN
----------------------------------------------------------------------------------------------------------
-- 작업구분
----------------------------------------------------------------------------------------------------------
    IF iJOBMODE = 'CREATE_PATTERN_NAME' THEN
        GOTO CREATE_PATTERN_NAME;
    ELSIF iJOBMODE = 'UPDATE_PATTERN_NAME' THEN
        GOTO UPDATE_PATTERN_NAME;
    ELSIF iJOBMODE = 'DELETE_PATTERN_NAME' THEN
        GOTO DELETE_PATTERN_NAME;
    END IF;

----------------------------------------------------------------------------------------------------------
-- PATTERN NAME 추가
----------------------------------------------------------------------------------------------------------
<<CREATE_PATTERN_NAME>>
	INSERT INTO	STDPATTERN (OBJECTID, SECTION, NAME)
	VALUES (SEQ_STDPATTERN.NEXTVAL, iSECTION, iPATTERN);
	RETURN;
----------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------
-- PATTERN NAME 수정
----------------------------------------------------------------------------------------------------------
<<UPDATE_PATTERN_NAME>>
	UPDATE	STDPATTERN A
	SET		A.SECTION		= iSECTION,
			A.NAME			= iPATTERN,
			A.MODIFY_DATE	= SYSDATE
	WHERE A.OBJECTID		= iOBJECTID;
	RETURN;
----------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------
-- PATTERN NAME 삭제
----------------------------------------------------------------------------------------------------------
<<DELETE_PATTERN_NAME>>
	DELETE	FROM	STDPATTERN A
	WHERE			A.OBJECTID	= iOBJECTID AND
					A.SECTION	= iSECTION;
	RETURN;
----------------------------------------------------------------------------------------------------------
END SP_CODE_PATTERN_CUD;
